﻿<Camera OnInit="@OnInit" OnStart="@OnStart" OnClose="@OnClose" OnError="@OnError" OnCapture="@OnCapture" />
<Logger @ref="Trace" class="mt-3" />

@code {
    private Logger Trace { get; set; }

    private Task OnInit(IEnumerable<DeviceItem> devices)
    {
        var cams = string.Join("", devices.Select(i => i.Label));
        Trace?.Log($"初始化摄像头完成 {cams}");
        return Task.CompletedTask;
    }

    private Task OnError(string err)
    {
        Trace?.Log("发生错误 {err}");
        return Task.CompletedTask;
    }

    private Task OnStart()
    {
        Trace?.Log("打开摄像头");
        return Task.CompletedTask;
    }

    private Task OnClose()
    {
        Trace?.Log("关闭摄像头");
        return Task.CompletedTask;
    }

    private Task OnCapture()
    {
        Trace?.Log("拍照完成");
        return Task.CompletedTask;
    }
}